﻿Option Strict Off
Public Class BBrowserSettings

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub BBrowserSettings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If My.Settings.UseBBrowserHomePage = "False" Then
            UseHomePageRadioButton.Checked = True
            DontUseHomePageRadioButton.Checked = False
        ElseIf My.Settings.UseBBrowserHomePage = "True" Then
            UseHomePageRadioButton.Checked = False
            DontUseHomePageRadioButton.Checked = True
        End If

        TextBox1.Text = My.Settings.BBrowserHomePageUrl
        ComboBox1.SelectedItem = My.Settings.ShowHomePageAtStartUp

        If My.Settings.TabsEnabledDefault = "None" Then
            AskMeRadioButton.Checked = True
            TabsRadioButton.Checked = False
            WithoutTabsRadioButton.Checked = False
        ElseIf My.Settings.TabsEnabledDefault = "With Tabs" Then
            AskMeRadioButton.Checked = False
            TabsRadioButton.Checked = True
            WithoutTabsRadioButton.Checked = False
        ElseIf My.Settings.TabsEnabledDefault = "Without Tabs" Then
            AskMeRadioButton.Checked = False
            TabsRadioButton.Checked = False
            WithoutTabsRadioButton.Checked = True
        End If

        If My.Settings.SplashScreenEnabled = "True" Then
            CheckBox1.Checked = True
        ElseIf My.Settings.SplashScreenEnabled = "False" Then
            CheckBox1.Checked = False
        End If

        If My.Settings.OpenNewWindowInNewTab = False Then
            RadioButtonNoNewTabWindow.Checked = True
            RadioButtonYesNewTabWindow.Checked = False
        ElseIf My.Settings.OpenNewWindowInNewTab = True Then
            RadioButtonNoNewTabWindow.Checked = False
            RadioButtonYesNewTabWindow.Checked = True
        End If

        If My.Settings.CloseAfterUnhandledException = False Then
            CloseBBrowserIfUnhandledNo.Checked = True
            CloseBBrowserIfUnhandledYes.Checked = False
        ElseIf My.Settings.CloseAfterUnhandledException = True Then
            CloseBBrowserIfUnhandledNo.Checked = False
            CloseBBrowserIfUnhandledYes.Checked = True
        End If

        Button3.Enabled = False
    End Sub

    Private Sub UseHomePageRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UseHomePageRadioButton.CheckedChanged
        If UseHomePageRadioButton.Checked = True Then
            Label1.ForeColor = Color.Gray
            TextBox1.Enabled = False
        ElseIf UseHomePageRadioButton.Checked = False Then
            Label1.ForeColor = Color.Black
            TextBox1.Enabled = True
        End If

        Button3.Enabled = True
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        If UseHomePageRadioButton.Checked = True Then
            My.Settings.UseBBrowserHomePage = "False"
        ElseIf DontUseHomePageRadioButton.Checked = True Then
            My.Settings.UseBBrowserHomePage = "True"
        End If

        My.Settings.BBrowserHomePageUrl = TextBox1.Text
        My.Settings.ShowHomePageAtStartUp = ComboBox1.SelectedItem

        If TabsRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "With Tabs"
        ElseIf WithoutTabsRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "Without Tabs"
        ElseIf AskMeRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "None"
        End If

        If CheckBox1.Checked = True Then
            My.Settings.SplashScreenEnabled = "True"
        ElseIf CheckBox1.Checked = False Then
            My.Settings.SplashScreenEnabled = "False"
        End If

        If RadioButtonNoNewTabWindow.Checked = True Then
            My.Settings.OpenNewWindowInNewTab = False
        ElseIf RadioButtonYesNewTabWindow.Checked = True Then
            My.Settings.OpenNewWindowInNewTab = True
        End If

        If CloseBBrowserIfUnhandledNo.Checked = True Then
            My.Settings.CloseAfterUnhandledException = False
        ElseIf CloseBBrowserIfUnhandledYes.Checked = True Then
            My.Settings.CloseAfterUnhandledException = True
        End If

        My.Settings.Save()

        Button3.Enabled = False
    End Sub

    Private Sub DontUseHomePageRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DontUseHomePageRadioButton.CheckedChanged
        Button3.Enabled = True
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Button3.Enabled = True
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Button3.Enabled = True
    End Sub

    Private Sub TabsRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabsRadioButton.CheckedChanged
        Button3.Enabled = True
    End Sub

    Private Sub WithoutTabsRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WithoutTabsRadioButton.CheckedChanged
        Button3.Enabled = True
    End Sub

    Private Sub AskMeRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AskMeRadioButton.CheckedChanged
        Button3.Enabled = True
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        Button3.Enabled = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If UseHomePageRadioButton.Checked = True Then
            My.Settings.UseBBrowserHomePage = "False"
        ElseIf DontUseHomePageRadioButton.Checked = True Then
            My.Settings.UseBBrowserHomePage = "True"
        End If

        My.Settings.BBrowserHomePageUrl = TextBox1.Text
        My.Settings.ShowHomePageAtStartUp = ComboBox1.SelectedItem

        If TabsRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "With Tabs"
        ElseIf WithoutTabsRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "Without Tabs"
        ElseIf AskMeRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "None"
        End If

        If CheckBox1.Checked = True Then
            My.Settings.SplashScreenEnabled = "True"
        ElseIf CheckBox1.Checked = False Then
            My.Settings.SplashScreenEnabled = "False"
        End If

        If RadioButtonNoNewTabWindow.Checked = True Then
            My.Settings.OpenNewWindowInNewTab = False
        ElseIf RadioButtonYesNewTabWindow.Checked = True Then
            My.Settings.OpenNewWindowInNewTab = True
        End If

        If CloseBBrowserIfUnhandledNo.Checked = True Then
            My.Settings.CloseAfterUnhandledException = False
        ElseIf CloseBBrowserIfUnhandledYes.Checked = True Then
            My.Settings.CloseAfterUnhandledException = True
        End If

        My.Settings.Save()

        Button3.Enabled = False

        Me.Close()
    End Sub

    Private Sub ApplyChanges()

        If UseHomePageRadioButton.Checked = True Then
            My.Settings.UseBBrowserHomePage = "False"
        ElseIf UseHomePageRadioButton.Checked = False Then
            My.Settings.UseBBrowserHomePage = "True"
        End If

        My.Settings.BBrowserHomePageUrl = TextBox1.Text
        My.Settings.ShowHomePageAtStartUp = ComboBox1.SelectedItem

        If TabsRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "With Tabs"
        ElseIf WithoutTabsRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "Without Tabs"
        ElseIf AskMeRadioButton.Checked = True Then
            My.Settings.TabsEnabledDefault = "None"
        End If

        If CheckBox1.Checked = True Then
            My.Settings.SplashScreenEnabled = "True"
        ElseIf CheckBox1.Checked = False Then
            My.Settings.SplashScreenEnabled = "False"
        End If

        If RadioButtonNoNewTabWindow.Checked = True Then
            My.Settings.OpenNewWindowInNewTab = False
        ElseIf RadioButtonYesNewTabWindow.Checked = True Then
            My.Settings.OpenNewWindowInNewTab = True
        End If

        If CloseBBrowserIfUnhandledNo.Checked = True Then
            My.Settings.CloseAfterUnhandledException = False
        ElseIf CloseBBrowserIfUnhandledYes.Checked = True Then
            My.Settings.CloseAfterUnhandledException = True
        End If

        My.Settings.Save()

        Button3.Enabled = False

    End Sub

    Private Sub RadioButtonNoNewTabWindow_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonNoNewTabWindow.CheckedChanged
        Button3.Enabled = True
    End Sub

    Private Sub RadioButtonYesNewTabWindow_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonYesNewTabWindow.CheckedChanged
        Button3.Enabled = True
    End Sub

    Private Sub CloseBBrowserIfUnhandledNo_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CloseBBrowserIfUnhandledNo.CheckedChanged
        Button3.Enabled = True
    End Sub

    Private Sub CloseBBrowserIfUnhandledYes_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CloseBBrowserIfUnhandledYes.CheckedChanged
        Button3.Enabled = True
    End Sub
End Class